/*
 * File:   densitySP.hpp
 * Author: gian
 *
 * Created on December 12, 2012, 4:50 PM
 */

#ifndef DENSITYSP_HPP
#define DENSITYSP_HPP
#define MAX_THREADS 50

#include <pthread.h>
#include <vector>
#include "latticeSP.hpp"

class densitySP {
  public:
    densitySP(int    lsizex,
                int    lsizey,
                int    lsizez,
                int    nx,
                int    ny,
                int    nz);

    virtual ~densitySP();

    void operator ()(latticeSP & l);

    double color_density(int n);

    double total_density();

  private:
    static void placca(nodeSP *              n1,
                       nodeSP *              n2,
                       nodeSP *              n3,
                       nodeSP *              n4,
                       std::vector<double> & String,
                       std::vector<double> & Density);

    struct measure_thread_args {
      latticeSP* l;
      std::vector<double> *String;
      std::vector<double> *Density;
      int xmin;
      int xmax;
      int ymin;
      int ymax;
      int zmin;
      int zmax;
    };


    int                   mThreadNumber;
    measure_thread_args * mThreadArguments;
    pthread_t             mThreads[MAX_THREADS];

    static void * measure_thread(void * args);

    std::vector<double> mDensity;
    std::vector<double> mString;
};
#endif /* DENSITYSP_HPP */


//~ Formatted by Jindent --- http://www.jindent.com
